package com.nbsaas.boot.wms.data.entity;

import com.nbsaas.boot.code.annotation.*;
import com.nbsaas.boot.jpa.data.entity.AbstractEntity;
import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import jakarta.persistence.Table;
import lombok.Data;
import org.hibernate.annotations.Comment;

import java.math.BigDecimal;
import java.util.Date;

@CreateByUser
@ComposeView
@Data
@FormAnnotation(title = "入库单", model = "入库单")
@Entity
@Table(name = "bs_stock_in_order")
@Comment("入库单表")
public class StockInOrder extends AbstractEntity {

    @Comment("入库单号")
    @SearchItem(name = "orderNo", key = "orderNo", label = "入库单号")
    @FormField(title = "入库单号", sortNum = "1", grid = true, required = true)
    @Column(length = 100, nullable = false, unique = true)
    private String orderNo;

    @Comment("入库类型")
    @FormField(title = "入库类型", sortNum = "2", grid = true, type = InputType.select)
    @Column(length = 20)
    private String type; // PURCHASE-采购入库, RETURN-退货入库, TRANSFER-调拨入库, OTHER-其他入库

    @Comment("仓库ID")
    @FormField(title = "仓库ID", sortNum = "3", grid = true, required = true)
    private Long warehouseId;

    @Comment("供应商ID")
    @FormField(title = "供应商ID", sortNum = "4", grid = true)
    private Long supplierId;

    @Comment("供应商名称")
    @FormField(title = "供应商名称", sortNum = "5", grid = true)
    @Column(length = 200)
    private String supplierName;

    @Comment("预计入库时间")
    @FormField(title = "预计入库时间", sortNum = "6", grid = true, type = InputType.date)
    private Date expectedInTime;

    @Comment("实际入库时间")
    @FormField(title = "实际入库时间", sortNum = "7", grid = true, type = InputType.date)
    private Date actualInTime;

    @Comment("入库总数量")
    @FormField(title = "入库总数量", sortNum = "8", grid = true, type = InputType.el_input_number, sort = true)
    private Integer totalQuantity;

    @Comment("入库总金额")
    @FormField(title = "入库总金额", sortNum = "9", grid = true, type = InputType.el_input_number, sort = true)
    @Column(precision = 10, scale = 2)
    private BigDecimal totalAmount;

    @Comment("入库单状态")
    @FormField(title = "入库单状态", sortNum = "10", grid = true, type = InputType.select)
    @Column(length = 20)
    private String status; // DRAFT-草稿, PENDING-待审核, APPROVED-已审核, PROCESSING-处理中, COMPLETED-已完成, CANCELLED-已取消

    @Comment("审核人ID")
    @FormField(title = "审核人ID", sortNum = "11", grid = true)
    private Long approverId;

    @Comment("审核时间")
    @FormField(title = "审核时间", sortNum = "12", grid = true, type = InputType.date)
    private Date approveTime;

    @Comment("审核备注")
    @FormField(title = "审核备注", sortNum = "13", type = InputType.richText, col = 23)
    @Column(length = 1000)
    private String approveNote;

    @Comment("关联单据号")
    @FormField(title = "关联单据号", sortNum = "14", grid = true)
    @Column(length = 100)
    private String relatedOrderNo;

    @Comment("关联单据类型")
    @FormField(title = "关联单据类型", sortNum = "15", grid = true, type = InputType.select)
    @Column(length = 20)
    private String relatedOrderType; // PURCHASE_ORDER-采购单, SALE_ORDER-销售单, TRANSFER_ORDER-调拨单

    @Comment("备注")
    @FormField(title = "备注", sortNum = "16", type = InputType.richText, col = 23)
    @Column(length = 1000)
    private String note;
} 